package day07;

import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class StreamApiTest {

    public static void main(String[] args) {
        // 创建stream
        List<Person> list = Person.list();
        // default Stream<E> stream()：返回一个顺序流
        Stream<Person> stream = list.stream();
        // default Stream<E> parallelStream()：返回并行流
        Stream<Person> personStream = list.parallelStream();

        // 存入数组，创建
        IntStream stream1 = Arrays.stream(new int[]{1, 2, 3, 4, 5, 6, 7});
        Stream<Object> cc = Arrays.stream(new Object[]{new Person("cc", 12)});

        // of创建
        Stream<Integer> integerStream = Stream.of(1, 2, 3, 4, 5, 6, 7, 78, 8);

        // 无限流
        Stream.iterate(0, t -> t + 2).limit(10).forEach(System.out::println);


    }

}
